package com.example.androidframework.ui.goods

import android.view.View
import androidx.lifecycle.MutableLiveData
import com.example.androidframework.ui.goods.holder.ServiceDescViewHolder
import com.martin.lib_base.base.BaseViewModel
import com.martin.lib_base.bean.app.exchange.GoodsCategoryBean
import com.martin.lib_base.bean.app.goods.GoodsDetailBean
import com.martin.lib_base.ktx_live.buildRequest
import com.martin.lib_base.ktx_live.launchCollect
import com.martin.lib_base.ktx_live.launchLoadingCollect
import com.martin.lib_base.net.NetApply

class GoodsDetailViewModel : BaseViewModel() {
    var goodsId = ""
    var detailBean = MutableLiveData<GoodsDetailBean>()
    val serviceDescViewHolder = listOf(ServiceDescViewHolder::class.java)

    // 商品详情数据
    fun getGoodsDetailData() {
        launchLoadingCollect({
            NetApply.api.getGoodsDetailData(
                buildRequest(
                    "Shop.GetGoodsInfo",
                    mapOf(
                        "goodsid" to goodsId
                    )
                )
            )
        }) {
            onSuccess = {
                it.info?.let {
                    detailBean.value = it
                }
            }
        }
    }

    fun goBack() {
        finish()
    }

    fun goStore(view: View) {

    }

    fun callService(view: View) {

    }

    fun goCart(view: View) {

    }

    fun joinCart(view: View) {

    }

    fun buyNow(view: View) {

    }
}